package com.flc.realtime;

import com.flc.realtime.config.AppConfig;
import com.flc.realtime.mq.consumer.*;
import com.flc.realtime.redis.RedisPool;
import org.apache.rocketmq.client.exception.MQClientException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.Jedis;

/**
 * 设备上报数据归档程序
 * @author haizi
 * @date 2018-2-2日
 */
public class Realtime {

    private static final Logger logger = LoggerFactory.getLogger(Realtime.class);

    public static Jedis reportJedis;
    public static Jedis trajectoryJedis;
    public static Jedis diagnosisJedis;
    //public static Jedis simpleJedis;

    public static void main( String[] args ) {

        AppConfig.RedisCfg redisCfg = AppConfig.getInstance().getRedisCfg();

        RedisPool.init(redisCfg);

        Consumer reportConsumer = ConsumerFactory.getConsumer(ReportConsumer.class);
        Consumer trajectoryConsumer = ConsumerFactory.getConsumer(TrajectoryConsumer.class);
        Consumer diagnosisConsumer = ConsumerFactory.getConsumer(DiagnosisConsumer.class);
        //Consumer simpleConsumer = ConsumerFactory.getConsumer(SimpleConsumer.class);

        reportJedis = RedisPool.getJedis();
        trajectoryJedis = RedisPool.getJedis();
        diagnosisJedis = RedisPool.getJedis();
        //simpleJedis = RedisPool.getJedis();

        try {
            //simpleConsumer.start();
            trajectoryConsumer.start();
            reportConsumer.start();
            diagnosisConsumer.start();

        } catch (MQClientException e) {
            logger.error("未能打开MQ客户端的错误");
            e.printStackTrace();
        }
    }
}
